﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Ah.Testudin.Engine.Graphics
{
    public class GraphicsDeviceRendererSingleton
    {
        #region Private Member Variables

        private static ITestudinRenderer _instance;

        #endregion

        #region Properties

        public static ITestudinRenderer Instance
        {
            get
            {
                if (_instance == null)
                {
                    throw new Exception("Graphics device singleton not initialized");
                }

                return _instance;
            }
        }

        #endregion

        #region Constructors

        private GraphicsDeviceRendererSingleton()
        {
        }

        #endregion

        #region Public Methods

        public static void Initialize(
            GraphicsDevice graphicsDeviceManager,
            SpriteBatch spriteBatch)
        {
            if (graphicsDeviceManager == null)
            {
                throw new ArgumentNullException("graphicsDeviceManager");
            }

            if (spriteBatch == null)
            {
                throw new ArgumentNullException("spriteBatch");
            }

            _instance = new GraphicsDeviceRenderer(
                graphicsDeviceManager,
                spriteBatch);
        }

        #endregion
    }
}
